//
//  HTUsers.swift
//  mySinaBlog
//
//  Created by whtapple on 3/27/16.
//  Copyright © 2016 whtapple. All rights reserved.
//

import UIKit
///用户信息
class HTUsers: NSObject {
    ///用户 ID
    var id: Int64 = 0
    //用户头像地址（中图）
    var profile_image_url: String?
    //用户昵称
    var screen_name: String?
    //会员等级 1 - 6
    var mbrank: Int = 0{
        didSet{
            //根据会员等级设置等级图标
            if mbrank > 0 && mbrank <= 6{
                let imagename = "common_icon_membership_level\(mbrank)"
                mbrankImage = UIImage(named: imagename)
            }else{
                mbrankImage = nil
            }
        }
    }
    //会员等级图标
    var mbrankImage: UIImage?
    //verified_type 没有认证:-1   认证用户:0  企业认证:2,3,5  达人:220
    var verified_type: Int = -1{
        didSet{
            //根据返回的认证数值，确定显示认证图标
            switch verified_type{
            case 0:
                verified_typeImage =  UIImage(named: "avatar_vip")
            case 2,3,5:
                 verified_typeImage =  UIImage(named: "avatar_enterprise_vip")
            case 220:
                verified_typeImage =  UIImage(named: "avatar_grassroot")
            default:
                verified_typeImage =  nil
            }
        }
    }
    //认证图标
    var verified_typeImage: UIImage?
    ///字典转模型
    init(dict:[String : AnyObject]) {
        super.init()
        setValuesForKeysWithDictionary(dict)
    }
    ///设置当value没有对应的属性的时候，调用
    override func setValue(value: AnyObject?, forUndefinedKey key: String) {}
    ///对象输出
    override var description: String {
        let keys = ["id","profile_image_url","screen_name","mbrank","verified_type"]
        return "\n\t\(dictionaryWithValuesForKeys(keys))"
    }
}
